package smb.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import smb.service.AdminService;
import smb.vo.StudentPage;
import smb.vo.StudentRankPage;
import smb.vo.StudentVo;

@RestController
@RequestMapping("/admin")
@AllArgsConstructor
public class AdminController {
    private AdminService adminService;

    @GetMapping("/student/{pageSize}/{pageNum}")
    public StudentPage getStudents(@PathVariable int pageSize, @PathVariable int pageNum) {
        return adminService.getStudents(pageSize, pageNum);
    }

    @PostMapping("/student/{id}")
    public void postStudent(@PathVariable(required = false) String id, @RequestBody StudentVo studentVo) {
        adminService.postStudent(studentVo);
    }

    @PutMapping("/student/{id}")
    public void putStudent(@PathVariable(required = false) String id, @RequestBody StudentVo studentVo) {
        adminService.putStudent(studentVo);
    }

    @DeleteMapping("/student/{id}")
    public void deleteStudent(@PathVariable String id) {
        adminService.deleteStudent(id);
    }

    @GetMapping("/student/rank/{pageSize}/{pageNum}")
    public StudentRankPage getRank(@PathVariable int pageSize, @PathVariable int pageNum) {
        return adminService.getRank(pageSize, pageNum);
    }

}
